﻿using Process.Domain.Entities;
using Process.Infrastructure.Repositories;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WorkflowCore.Interface;
using WorkflowCore.Models;

namespace Process.Domain.Steps
{
    public class EndStep : StepBody
    {
        public readonly IProcessRepository<ProcessAuditModel> _processautiModel;
      
        public EndStep( IProcessRepository<ProcessAuditModel> processautiModel)
        {        
            _processautiModel = processautiModel;
        }
        public override ExecutionResult Run(IStepExecutionContext context)
        {
            var data = _processautiModel.GetValue().Where(x => x.WorkflowId == context.Workflow.Id).FirstOrDefault();
         var model=   new ProcessAuditModel
            {

                
                CreatedAt = DateTime.Now,
                AuditType = "审批通过",
                Status = "已审批"
            };
            data.Status=model.Status; 
            data.CreatedAt=model.CreatedAt;
            data.AuditType=model.AuditType;

            Console.WriteLine("审批结束");
            return ExecutionResult.Next();
        }
    }
}
